﻿using System;
using System.Windows.Forms;

namespace HYCodeBase.WinForm.WinFormRemindSuit
{
	internal class CustomAttributeGetterSetter : IAttributeGeter, IAttributeSeter
	{
		internal CustomAttributeGetterSetter(ControlPacker inputControlPacker)
		{
			this.m_thisCustomFormatter = inputControlPacker.UseCustomFormatter;
		}

		public AttributeInformationBean GetOneAttributeBean(System.Windows.Forms.Control inputControl, string inputAttributeName)
		{
			string controlStr = this.m_thisCustomFormatter.GetControlStr(inputControl);
			return new AttributeInformationBean(inputAttributeName, controlStr);
		}

		public bool TrySetOneAttribute(ref System.Windows.Forms.Control inputControl, AttributeInformationBean inputAttribute)
		{
			bool result;
			try
			{
				this.m_thisCustomFormatter.SetControlStr(ref inputControl, inputAttribute.StrValueString);
				result = true;
			}
			catch (Exception)
			{
				result = false;
			}
			return result;
		}

		private ICustomControlInfoTransform m_thisCustomFormatter;
	}
}
